
package com.yuantu.judiciary.dao;

import com.yuantu.judiciary.model.domain.MonitorRecordDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;


/**
 * 账号数据库操作
 *
 * @author syw
 * @since 2023-08-03
 **/
public interface IMonitorRecordDao extends JpaRepository<MonitorRecordDO, Long> {


    MonitorRecordDO findInfoByIdAndDisabledFalse(Long id);

    MonitorRecordDO findInfoByOrderIdAndDisabledFalse(Long orderId);

    List<MonitorRecordDO> findInfosByCreatorIdAndIsPayTrueAndDisabledFalse(Long creatorId);

    List<MonitorRecordDO> findInfosByMonitorContentAndIsPayTrueAndDisabledFalse(String monitorContent);

    List<MonitorRecordDO> findInfosByIsPayTrueAndDisabledFalse();

    @Query(nativeQuery = true, value = "select * from monitor_record where creator_id = :creatorId and is_pay = true " +
            "and if(:monitorType is not null, monitor_type = :monitorType, 0=0) " )
    List<MonitorRecordDO> findInfosByMonitorTypeAndCreatorIdAndIsPayTrue(@Param("monitorType") Integer monitorType,
                                                                         @Param("creatorId") Long creatorId);
}
